package cn.vendpay.com.service;

import cn.vendcommon.com.entity.YOLORecognitionLog;
import cn.vendpay.com.mapper.YOLORecognitionLogMapper;
import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


@Service
public class YoloService {
    @Resource
    private YOLORecognitionLogMapper yolorecognitionLogMapper;

    @GlobalTransactional(rollbackFor = Exception.class)
    public void testTransaction() {
        YOLORecognitionLog yoloRecognitionLog = YOLORecognitionLog.builder()
                .phone("13800000000")
                .machineId(1)
                .status(1)
                .createTime(LocalDateTime.now())
                .inventoryMap("{}")
                .build();
        yolorecognitionLogMapper.insert(yoloRecognitionLog);

        int i = 1 / 0; // 模拟异常
    }
}
